#pragma once
#include "vn/Directory.h"

void DirectoryTest() {_test_func_;
	{_block_("GetCurrent & SetCurrent");
		REQUIRE_EXCEPTION( Directory::SetCurrent("c:\\khong_co") );
		Directory::SetCurrent("c:\\windows");
		assert( Directory::GetCurrent() == "c:\\windows" );
	}

	{_block_("Create: remove - create - create exist exception");
		Directory::Remove("c:\\_a_");
		Directory::Create("c:\\_a_");
		REQUIRE_EXCEPTION( Directory::Create("c:\\_a_") );
	}

	{_block_("Remove: recreate then remove");
		REQUIRE_EXCEPTION( Directory::Remove("!@#$%^&*") );

		Directory::Remove("c:\\_a_");
		Directory::Create("c:\\_a_");
		assert( Directory::Remove("c:\\_a_") == true );
		assert( Directory::Remove("c:\\_a_") == false );
	}

	{_block_("Move: recreate a folder then move 3 times");
		Directory::Remove("c:\\_a_");
		Directory::Remove("c:\\_b_");
		Directory::Remove("c:\\_c_");
		Directory::Create("c:\\_a_");

		Directory::Move("c:\\_a_", "c:\\_b_");
		Directory::Move("c:\\_b_\\", "c:\\_c_\\");
		Directory::Move("c:\\_c_\\.", "c:\\_a_\\");

		assert(Directory::Exists("c:\\_a_") == true);
		assert(Directory::Exists("d:\\_b_") == false);
	}

	{_block_("Set/GetAttributes: recreate then getset atribute");
		REQUIRE_EXCEPTION( Directory::GetAttributes("khong co") );
		Directory::Remove("c:\\_a_");
		Directory::Create("c:\\_a_");
		assert(Directory::GetAttributes("c:\\_a_") & FileAttributes::Directory);
		Directory::SetAttributes("c:\\_a_", Directory::GetAttributes("c:\\_a_") | FileAttributes::Hidden);
		assert(Directory::GetAttributes("c:\\_a_") & FileAttributes::Hidden);
	}

	{_block_("Exist");
		assert( Directory::Exists("c:\\khongco") == false);
		assert( Directory::Exists("c:\\windows") == true);
	}
}
